package com.gable.report.util;


import org.apache.commons.httpclient.Header;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: 杨青桦
 * @Description:  调用hospital项目接口工具类
 * @Date: 2017/11/28 15:33
 */
public class HttpProcessUtil {

    private static final Log logger = LogFactory.getLog(HttpProcessUtil.class);

    private static final String context = "/hospital/";   //医院项目名称

    private static final String serverName = "192.168.1.189"; //测试使用接口对接

    private static final String urlAppend = "charts/";  //医院项目报表调用接口添加路径

    public static  List<Header> headerList = Arrays.asList(new Header("report", "auth")); //头信息用于权限验证


    /** 
     * @Author: 杨青桦
     * @Description:  获取hospital项目接口访问路径
     * @Date: 2017/11/28 15:43
     * @param request
     * @param url
     * @return
     */
    public static String getAccessPath(HttpServletRequest request,String url){
        StringBuffer sb = new StringBuffer();
        sb.append(request.getScheme() + "://");
        //本地使用
        /*sb.append(serverName + ":");
        sb.append("8087" + context);*/
        //上线使用
        sb.append(request.getServerName() + ":");
        sb.append(request.getServerPort() + context);

        sb.append(urlAppend + url);
        return sb.toString();
    }

}
